package com.tanhua.model.vo;

import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.PeachblossomVoice;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

/**
 * @author げっしょく
 * @date 2021/11/7
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class VoiceVo {

    private Integer id;            // 用户id
    private String avatar;         // 头像
    private String nickname;       // 昵称
    private String gender;         // 性别
    private Integer age;           // 年龄
    private String soundUrl;       // 语音地址
    private Integer remainingTimes;// 剩余次数

    public static VoiceVo init(UserInfo userInfo, PeachblossomVoice peachblossomVoice, Integer count) {
        VoiceVo vo = new VoiceVo();
        vo.setId(Integer.valueOf(userInfo.getId().toString()));
        BeanUtils.copyProperties(userInfo, vo);
        vo.setSoundUrl(peachblossomVoice.getVoiceUrl());
        vo.setRemainingTimes(count);
        return vo;
    }
}
